﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Demo
{
    public class AppConfigHelper
    {
        public static string GetStrategyName()
        {
            string factoryName = null;
            try
            {
                //可以放配置文件
                factoryName = "Demo.ChildrenDiscount, Demo";
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return factoryName;
        }

        public static object GetStrategyInstance()
        {
            string assemblyName = AppConfigHelper.GetStrategyName();
            Type type = Type.GetType(assemblyName);

            var instance = Activator.CreateInstance(type);
            return instance;
        }
    }
}
